<template>
    <div>
         <!-- 分页器 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[5, 10, 20, 50, 100]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
    </div>
</template>
<script>
import { getTableData } from "@/utils/table.js";
export default{
    props:{
        'total':Number,
        'url':String
    },
    data(){
        return {
            currentPage: 1, //当前页数
            pageSize: 5, //每页显示条数
        }
    },
    created() {
        console.log(this.$parent)
    getTableData(
      this.$parent,
      this.url,
      { page: this.currentPage, size: this.pageSize },
      ["completed"]
    );
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      getTableData(this.$parent, this.url, { page: this.currentPage, size: val }, [
        "completed",
      ]);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      getTableData(this.$parent, this.url, { page: val, size: this.pageSize }, [
        "completed",
      ]);
    },
  },
}
</script>